<?php
namespace app\wadmin\controller;
// +----------------------------------------------------------------------
// | bbcThink
// +----------------------------------------------------------------------
// | Copyright (c) 2025 http://bbcweb.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: bbcweb <22745529@qq.com>
// +----------------------------------------------------------------------
use app\BaseController;
use think\facade\Db;
use think\facade\View;

//单页内容
class Single extends BaseController
{
    public $table = 'article';
    public function initialize()
    {
        parent::initialize();
    }
    public function index()
    {
        $p=input();
        $data=[];
        $category=[];
        if(!empty($p['tag']))
        {
            $category=\app\service\CategoryService::infoByTag(['where'=>['sign'=>$p['tag']]]);
            if($category)
            {
                View::assign('category',$category);
                $where=[['category_id','=',$category['id']],['country_id','=',cache('lang_id')]];
                
                if(!empty($p['keyword']))
                {
                    $where[]=['title','like','%'.$p['keyword'].'%'];
                }
                $params['where']=$where;
                $data= \app\service\ArticleService::info($params);
                
            }
        }
        View::assign('category',$category);
        View::assign('data',$data);
        return View::fetch();
    }
}
